/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.skill.executor;

import com.lineage.server.model.L1Character;
import com.lineage.server.model.L1EffectSpawn;
import com.lineage.server.model.Instance.L1MonsterInstance;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.Instance.L1PetInstance;
import com.lineage.server.model.Instance.L1SummonInstance;
import com.lineage.server.model.skill.L1SkillExecutor;
import com.lineage.server.packetserver.S_Paralysis;
import com.lineage.server.packetserver.ServerBasePacket;

/**
 * Class <code>ShockStun</code> 骑士魔法:冲击之晕 (15/0).
 * 使用此技能必须装备双手的剑类武器，一定机率使目标晕眩，并造成伤害。此技能与魔防(MR)和魔法等级无关。（学习等级：50）
 * 魔力消耗:15
 * 延迟时间:8秒
 * 持续时间:6秒
 * 类型:攻击
 * 属性:无
 * 目标:玩家、NPC
 * 善恶:中立
 * 
 * @author jrwz
 * @version 2012-7-27上午12:06:22
 * @see com.lineage.server.model.skill.executor
 * @since JDK1.7
 */
public final class ShockStun extends L1SkillExecutor {
    /** 动画效果NPC编号:冲击之晕. */
    private static final int EFFECT = 81162;

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static L1SkillExecutor get() {
        return new ShockStun();
    }

    /** 骑士魔法:冲击之晕 (15/0). */
    private ShockStun() {
    }

    @Override
    public void execute(final L1Character user, final L1Character cha,
            final L1Character target, final int targetID, final int skillId,
            final int getBuffIconDuration) {
        if (cha instanceof L1PcInstance) {
            final L1PcInstance pc = (L1PcInstance) cha;
            final ServerBasePacket msg = new S_Paralysis(S_Paralysis.TYPE_STUN,
                    true);
            pc.sendPackets(msg);
        } else if ((cha instanceof L1MonsterInstance)
                || (cha instanceof L1SummonInstance)
                || (cha instanceof L1PetInstance)) {
            final L1NpcInstance npc = (L1NpcInstance) cha;
            npc.setParalyzed(true);
            npc.setParalysisTime(getBuffIconDuration);
        }
        L1EffectSpawn.getInstance().spawnEffect(EFFECT, getBuffIconDuration,
                cha.getX(), cha.getY(), cha.getMapId());
    }

    @Override
    public void stop(final L1Character cha, final int skillId) {
        if (cha instanceof L1PcInstance) {
            final L1PcInstance pc = (L1PcInstance) cha;
            final ServerBasePacket msg = new S_Paralysis(S_Paralysis.TYPE_STUN,
                    false);
            pc.sendPackets(msg);
        } else if ((cha instanceof L1MonsterInstance)
                || (cha instanceof L1SummonInstance)
                || (cha instanceof L1PetInstance)) {
            final L1NpcInstance npc = (L1NpcInstance) cha;
            npc.setParalyzed(false);
        }
    }
}
